package cn.wolfcode.crm.service.impl;

import cn.wolfcode.crm.domain.AgencyInfo;
import cn.wolfcode.crm.mapper.AgencyInfoMapper;
import cn.wolfcode.crm.query.AgencyInfoQueryObject;
import cn.wolfcode.crm.query.PageResult;
import cn.wolfcode.crm.service.IAgencyInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AgencyInfoServiceImpl implements IAgencyInfoService{
    @Autowired
    private AgencyInfoMapper agencyInfoMapper;

    public int deleteByPrimaryKey(Long id) {
        return agencyInfoMapper.deleteByPrimaryKey(id);
    }

    public int insert(AgencyInfo record) {
        return agencyInfoMapper.insert(record);
    }

    public AgencyInfo selectByPrimaryKey(Long id) {
        return agencyInfoMapper.selectByPrimaryKey(id);
    }

    public List<AgencyInfo> selectAll() {
        return agencyInfoMapper.selectAll();
    }

    public int updateByPrimaryKey(AgencyInfo record) {
        return agencyInfoMapper.updateByPrimaryKey(record);
    }

    //分页
    public PageResult query(AgencyInfoQueryObject qo){
        //查总数
        int total = agencyInfoMapper.queryForCount(qo);
         if(total==0){
             return new PageResult();
         }
         //查每页数据
        List<AgencyInfo> rows = agencyInfoMapper.queryForList(qo);

        return new PageResult(rows,total);
    }

    public void changeState(Long id) {
        agencyInfoMapper.changeState(id) ;
    }


}
